<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:p="http://primefaces.org/ui"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets">
<ui:composition template="/pages/home.xhtml">
	<ui:define name="title">
		<h:outputText value="#{text.titAcao}" />
	</ui:define>
	<ui:define name="js">
		<h:outputScript name="jquery.meioMask.1.1.3.js" library="js" />
		<script>
			$(document).ready(function(){
				$(".money-format")
					.setMask({
						mask: '99,999.999.999',
						type: 'reverse'
						
					});
				$(".number-format")
					.setMask({
						mask: '9',
						type: 'repeat'
						
					});
				
			});
		</script>
	</ui:define>
	
	<ui:define name="content">
		<p:fieldset id="fieldSetAcao" legend="#{text.lgdAcaoForm}" collapsed="true"
			toggleable="true" binding="#{acaoController.fieldSetAcao}">
			
			<h:inputHidden id="acaoId" value="#{acaoController.selectedAcao.id}" />
			
			<h:panelGrid id="pnlFields" columns="3" cellspacing="5">
			    <h:outputLabel for="cod" value="Código" />
				<p:inputMask id="cod"  size="50" maxlength="40"
					requiredMessage="#{message.requiredProgramaCodigo}"
					value="#{acaoController.selectedAcao.codigo}" mask="?9999999999" placeHolder=""/>
				<p:message for="cod" />
				
			      <h:outputLabel for="programa" value="Programa " />  
        		  <p:selectOneMenu id="programa" value="#{acaoController.selectedAcao.programa}"  converter="programaConverter">  
            			<f:selectItem itemLabel="Selecione..." itemValue="" />  
            			<f:selectItems value="#{acaoController.programas}" var="programa" itemLabel="#{programa.codigo}" itemValue="#{programa}"/>  
        		 </p:selectOneMenu> 
				<p:message for="programa" />
			     
			      <h:outputLabel for="orgao" value="Orgão " />  
        		  <p:selectOneMenu id="orgao" value="#{acaoController.selectedAcao.orgao}"  converter="orgaoConverter">  
            			<f:selectItem itemLabel="Selecione..." itemValue="" />  
            			<f:selectItems value="#{acaoController.orgaos}" var="orgao" itemLabel="#{orgao.descOrgao}" itemValue="#{orgao}"/>  
        		 </p:selectOneMenu> 
				<p:message for="orgao" />
			     
			      <h:outputLabel for="unidadeOrcamentaria" value="Unid. Orçamentária " />  
        		  <p:selectOneMenu id="unidadeOrcamentaria" value="#{acaoController.selectedAcao.unidadeOrcamentaria}"  converter="unidadeOrcamentariaConverter">  
            			<f:selectItem itemLabel="Selecione..." itemValue="" />  
            			<f:selectItems value="#{acaoController.unidadeOrcamentarias}" var="unidadeOrcamentaria" itemLabel="#{unidadeOrcamentaria.nome}" itemValue="#{unidadeOrcamentaria}"/>  
        		 </p:selectOneMenu> 
				<p:message for="unidadeOrcamentaria" />
			
			
				<h:outputLabel for="descricao" value="#{text.lblAcaoDesc}" />
				<p:inputTextarea id="descricao" cols="40" rows="5" size="50" 
					value="#{acaoController.selectedAcao.descricao}" />
				<p:message for="descricao" />
			
				<h:outputLabel for="produto" value="Produto" />
				<p:inputTextarea id="produto" cols="40" rows="5" size="50" 
					value="#{acaoController.selectedAcao.produto}" />
				<p:message for="produto" />
				
				 <h:outputLabel for="situacao" value="Situação" />
			        <p:selectOneRadio id="situacao" value="#{acaoController.selectedAcao.situacao}">  
			            <f:selectItem itemLabel="Em andamento" itemValue="1" />  
			            <f:selectItem itemLabel="Nova" itemValue="0" />  
			        </p:selectOneRadio>  
				<p:message for="situacao" />
				
				 <h:outputLabel for="tipo" value="Tipo" />
			        <p:selectOneRadio id="tipo" value="#{acaoController.selectedAcao.tipo}">  
			            <f:selectItem itemLabel="Atividade" itemValue="1" />  
			            <f:selectItem itemLabel="Projeto" itemValue="2" />  
			            <f:selectItem itemLabel="Outros" itemValue="3" />  
			        </p:selectOneRadio>  
				<p:message for="tipo" />
				
				
				<h:outputLabel value="Ano 1"/>
				<h:panelGroup>
					<h:outputLabel value="Valor 1"/>
					<p:inputMask id="valor1"  size="20" maxlength="10"
						value="#{acaoController.selectedAcao.valor1}"   styleClass="money-format"/>
					<p:spacer width="20"/>
					<h:outputLabel value="Meta 1"/>
					<p:inputMask id="meta1"  size="20" maxlength="10"
						value="#{acaoController.selectedAcao.meta1}" styleClass="number-format" />
				</h:panelGroup>
				<h:panelGroup>
				</h:panelGroup>
				
				<h:outputLabel value="Ano 2"/>
				<h:panelGroup>
					<h:outputLabel value="Valor 2"/>
					<p:inputMask id="valor2"  size="20" maxlength="10"
						value="#{acaoController.selectedAcao.valor2}"  styleClass="money-format"/>
					<p:spacer width="20"/>
					<h:outputLabel value="Meta 2"/>
					<p:inputMask id="meta2"  size="20" maxlength="10"
						value="#{acaoController.selectedAcao.meta2}" styleClass="number-format"/>
				</h:panelGroup>
				<h:panelGroup>
				</h:panelGroup>
				
				<h:outputLabel value="Ano 3"/>
				<h:panelGroup>
					<h:outputLabel value="Valor 3"/>
					<p:inputMask id="valor3"  size="20" maxlength="10"
						value="#{acaoController.selectedAcao.valor3}"  styleClass="money-format" />
					<p:spacer width="20"/>
					<h:outputLabel value="Meta 3"/>
					<p:inputMask id="meta3"  size="20" maxlength="10"
						value="#{acaoController.selectedAcao.meta3}" styleClass="number-format" />
				</h:panelGroup>
				<h:panelGroup>
				</h:panelGroup>
				
				<h:outputLabel value="Ano 4"/>
				<h:panelGroup>
					<h:outputLabel value="Valor 4"/>
					<p:inputMask id="valor4"  size="20" maxlength="10" styleClass="money-format"
						value="#{acaoController.selectedAcao.valor4}" />
					<p:spacer width="20"/>
					<h:outputLabel value="Meta 4"/>
					<p:inputMask id="meta4"  size="20" maxlength="10"
						value="#{acaoController.selectedAcao.meta4}" styleClass="number-format"/>
				</h:panelGroup>
				<h:panelGroup>
				</h:panelGroup>

				<h:outputLabel for="unidadeMedida" value="#{text.lblUnidadeMedida}" />
				<p:inputText id="unidadeMedida"  size="50" maxlength="255"
					value="#{acaoController.selectedAcao.unidadeMedida}" />
				<p:message for="unidadeMedida" />
			</h:panelGrid>


			<p:separator />

			<p:commandButton id="btnNew" value="#{text.btnNew}"
				icon="ui-icon-document" actionListener="#{acaoController.newAcao}"
				immediate="true" update=":frmContent:fieldSetAcao"
				onclick="grdAcao.unselectAllRows();clearRadioDataTable();clearDataTableFilter(grdAcao);" />
			<p:commandButton id="btnSave" value="#{text.btnSave}"
				icon="ui-icon-disk"
				update=":frmContent:fieldSetAcao, :frmContent:grdAcao"
				actionListener="#{acaoController.saveAcao}"
				oncomplete="clearDataTableFilter(grdAcao);"
				process=":frmContent:fieldSetAcao" />
			<p:commandButton id="btnDelete" value="#{text.btnDelete}"
				icon="ui-icon-trash" onclick="dialogDelete.show()"
				binding="#{acaoController.btnDelete}" disabled="true" global="false"/>
			<p:confirmDialog id="dlgConfirmDelete" widgetVar="dialogDelete"
				closable="true" severity="info" appendToBody="true"
				header="#{text.dlgConfirm}" message="#{message.confirmDelete}"
				width="400">
				<p:commandButton id="btnConfirmDelete"
					actionListener="#{acaoController.deleteAcao}"
					value="#{text.btnConfirm}" icon="ui-icon-check"
					oncomplete="dialogDelete.hide(); clearDataTableFilter(grdAcao);"
					update=":frmContent:fieldSetAcao, :frmContent:grdAcao" />
				<p:commandButton id="btnDeclineDelete" onclick="dialogDelete.hide()"
					value="#{text.btnCancel}" icon="ui-icon-cancel" global="false"/>
			</p:confirmDialog>

		</p:fieldset>

		<p:spacer height="25" />

		<p:dataTable id="grdAcao" var="acao" paginatorPosition="bottom"
			value="#{acaoController.acaoDataModel}" widgetVar="grdAcao"
			emptyMessage="#{text.grdEmpty}"
			selection="#{acaoController.selectedAcao}" paginator="true"
			rows="10" rowsPerPageTemplate="10,25,50"
			paginatorTemplate=" {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
			style="width:600px;" sortBy="#{acao.descricao}" filterEvent="enter">

			<p:ajax event="rowSelect" update=":frmContent:fieldSetAcao"
				listener="#{acaoController.selectAcao}" />

			<p:column selectionMode="single" style="width:18px" />
			<p:column id="colAcaoCod" headerText="Código"
				sortBy="#{acao.codigo}" filterBy="#{acao.codigo}">
				<h:outputText value="#{acao.codigo}" />
			</p:column>
			<p:column id="colAcaoDesc" headerText="#{text.lblAcaoDesc}"
				sortBy="#{acao.descricao}"  filterBy="#{acao.descricao}">
				<h:outputText value="#{acao.descricao}" />
			</p:column>
		</p:dataTable>


	</ui:define>
</ui:composition>

</html>